package cc.lucien.web.service.serviceImpl;

import cc.lucien.web.dao.GoodsMapper;
import cc.lucien.web.entity.Goods;
import cc.lucien.web.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    GoodsMapper goodsMapper;

    @Override
    public List<Goods> selectAllGoods() {
        return goodsMapper.selectAllGoods();
    }

    @Override
    public void goodDelete(Integer id) {
        goodsMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void goodsSave(Goods goods) {
        goodsMapper.insert(goods);
    }

    @Override
    public Goods getGoodById(Integer id) {
        return goodsMapper.selectByPrimaryKey(id);
    }

    @Override
    public void goodUpdate(Goods goods) {
        goodsMapper.updateByPrimaryKey(goods);
    }

    @Override
    public void setStatusAs0(Integer id) {
        goodsMapper.setStatusAs0(id);
    }

    @Override
    public void setStatusAs1(Integer id) {
        goodsMapper.setStatusAs1(id);
    }

    @Override
    public String getImg(Integer id) {
        return goodsMapper.getImg(id);
    }

    @Override
    public void editGoodsPic(Integer id, String imgPath) {
        goodsMapper.editGoodsPic(id, imgPath);
    }

    @Override
    public List<Goods> selectGoodsStatusAs1() {
        return goodsMapper.selectGoodsStatusAs1();
    }

    @Override
    public List<Goods> selectGoodsByType(Integer id) {
        return goodsMapper.selectGoodsByType(id);
    }
}
